Skip to content

Fix forecast displaying "[Object object]" instead of card sides#2

Merged
chand1012 merged 5 commits intomainfrom
copilot/fix-1
Jul 25, 2025
Merged

Fix forecast displaying "[Object object]" instead of card sides#2
chand1012 merged 5 commits intomainfrom
copilot/fix-1

Conversation

Copy link
Copy Markdown

Copilot AI commented Jul 25, 2025

The forecast functionality was displaying "[Object object]" three times instead of showing the side of the next 3 cards (insider or visionary) as intended.

Root Cause

In components/game-controller.tsx, the code was attempting to join an array of Initiative objects directly:

message += `\n\nNext 3 cards: ${result.next_cards.join(", ")}`;

But result.next_cards is an array of Initiative objects with {type, text} properties, not strings. When JavaScript converts objects to strings in a join operation, they become "[object Object]".

Solution

Modified the forecast display logic to properly map Initiative objects to their meaningful card sides:

const cardTypes = result.next_cards.map(card => 
  card.type === 'growth' ? 'Visionary' : 'Insider'
);
message += `\n\nNext 3 cards: ${cardTypes.join(", ")}`;

Test Results

  • Before fix: "Next 3 cards: [object Object], [object Object], [object Object]"
  • After fix: "Next 3 cards: Visionary, Insider, Visionary"

The forecast action is available to COOs after 3 hostile initiatives have been passed, and now properly displays whether each upcoming card benefits the Visionary faction (growth initiatives) or Insider faction (hostile initiatives).

Hostile Takeover Application

Fixes #1.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/hostile-takeover/hostile-takeover/node_modules/next/dist/compiled/jest-worker/processChild.js (dns block)
    • Triggering command: next-server (v15.3.2) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel bot commented Jul 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hostile-takeover ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 11:38am

Co-authored-by: chand1012 <3521582+chand1012@users.noreply.github.com>
Co-authored-by: chand1012 <3521582+chand1012@users.noreply.github.com>
Copilot AI changed the title [WIP] Forecast doesn't work Fix forecast displaying "[Object object]" instead of card sides Jul 25, 2025
Copilot AI requested a review from chand1012 July 25, 2025 02:12
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type error in this file. Type error: Parameter 'card' implicitly has an 'any' type.

Please fix so that the vercel build succeeds.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the TypeScript error by adding the Initiative type import and properly typing the card parameter in the map function. Also updated to use the existing isGrowthInitiative() helper function for better consistency. The Vercel build should now succeed. (commit 8403ba1)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names of forecasted cards should be "growth" and "hostile" not "visionary" and "insider".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the forecast display to show "growth" and "hostile" card types instead of "Visionary" and "Insider" faction names. The forecast action now properly displays the card types themselves for better clarity. (commit b24a1db)

…rd parameter

Co-authored-by: chand1012 <3521582+chand1012@users.noreply.github.com>
Copy link
Copy Markdown
Owner

@chand1012 chand1012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names of forecasted cards should be "growth" and "hostile" not "visionary" and "insider".

…ry" and "Insider"

Co-authored-by: chand1012 <3521582+chand1012@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Jul 25, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/hostile-takeover/hostile-takeover/node_modules/next/dist/compiled/jest-worker/processChild.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Copy Markdown
Author

Copilot AI commented Jul 25, 2025

Names of forecasted cards should be "growth" and "hostile" not "visionary" and "insider".

The forecast display has already been updated to show "growth" and "hostile" instead of "Visionary" and "Insider" in commit b24a1db. The code now correctly displays card types rather than faction names.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/hostile-takeover/hostile-takeover/node_modules/next/dist/compiled/jest-worker/processChild.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@chand1012 chand1012 marked this pull request as ready for review July 25, 2025 11:48
Copilot AI review requested due to automatic review settings July 25, 2025 11:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where the forecast functionality was displaying "[Object object]" instead of the actual card types (growth or hostile) for the next 3 cards in the game.

  • Fixed object-to-string conversion issue in forecast display logic
  • Updated code to properly map Initiative objects to their readable card types
  • Added proper type import for Initiative interface

if (result.next_cards) {
message += `\n\nNext 3 cards: ${result.next_cards.join(", ")}`;
const cardTypes = result.next_cards.map((card: Initiative) =>
isGrowthInitiative(card) ? 'growth' : 'hostile'
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The card type mapping doesn't match the description. According to the PR description, growth initiatives should map to 'Visionary' and hostile initiatives should map to 'Insider', but the code maps them to 'growth' and 'hostile'.

Suggested change
isGrowthInitiative(card) ? 'growth' : 'hostile'
isGrowthInitiative(card) ? 'Visionary' : 'Insider'

Copilot uses AI. Check for mistakes.
@chand1012 chand1012 merged commit 0cbdb26 into main Jul 25, 2025
3 checks passed
@chand1012 chand1012 deleted the copilot/fix-1 branch July 25, 2025 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forecast doesn't work

3 participants